@extends('admin_system/public/angular-layout')
<body ng-app="admin-app" ng-controller="companyController" data-ng-init="departments = '{{$departments}}';add_member_init()">
<div class="main-container">

    {{--顶部导航--}}
    <div class="col-xs-12 top-nav nav">
        <p class="float-left nav-path"><strong>当前位置：</strong>公司管理>>导入用户</p>

        {{--返回按钮--}}
        <button type="button" class="btn btn-default float-right back" aria-label="Left Align">
            <span class="glyphicon glyphicon-arrow-left back" aria-hidden="true"></span>
            <span>返回</span>
        </button>
    </div>

    <div class="h10 col-xs-12"></div>
    {{--正文内容--}}

    <form action="" style="width:500px;">
        <table class="table table-bordered">
            <tr>
                <td>公司名称：</td>
                <td><input type="text" placeholder="点击选择用户" disabled class="form-control" value="{{$companyInfo->company_name}}"></td>
            </tr>

            <tr>
                <td>选择用户：</td>
                <td>
                    <input id="userName" placeholder="点击选择用户" readonly class="form-control" onclick="show_list()">
                    <input id="userId" type="hidden"  >
                </td>
            </tr>

            <tr>
                <td>选择读书会：</td>
                <td>
                    <select name=""  class="form-control" ng-model="companyMember.readParty" ng-change="select_read_party()">
                        <option value='0'>不加入读书会</option>
                        @foreach($readpartys as $read)
                            <option value="{{$read->ReaParID}}">{{$read->ReaParName}}</option>
                        @endforeach
                    </select>
                </td>
            </tr>

            <tr>
                <td>选择部门：</td>
                <td>
                    <select name="" class="form-control" ng-model="companyMember.department">
                        <option ng-repeat="dep in departments" ng-value="dep.department_id" ng-bind="dep.department_name" ng-hide="dep.read_party_id != companyMember.readParty"></option>
                        <option ng-value="0">不分部门</option>
                    </select>
                </td>
            </tr>


            <tr>
                <td>公司职位:</td>
                <td><input type="text" class="form-control" ng-model="companyMember.job"></td>
            </tr>

            <tr>
                <td>查看礼物权限:</td>
                <td>
                    <select  class="form-control" ng-model="companyMember.giftRight">
                        <option value=0>不可查看</option>
                        <option value=1>可查看</option>
                    </select>
                </td>
            </tr>

            <tr>
                <td>是否管理员：</td>
                <td>
                    <select  class="form-control" ng-model="companyMember.isManager">
                        <option value="0" >不是</option>
                        <option value="1" >是</option>
                    </select>
                </td>
            </tr>
        </table>

        <div class="mt20 text-center">
            <span class="btn btn-danger" ng-click="add_member()">&nbsp;确&nbsp;定&nbsp;</span>
        </div>

    </form>
    <!-- Modal -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document" style="width:800px;min-height:80vh;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">选择用户</h4>
                </div>
                <iframe src="{{asset('admin_system/member/select_member?callback=callback')}}" style="min-height:85vh;width:100%;"></iframe>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    function callback(data){
        if(data &&　data.length > 0){
            data = data[0];
            $('#userId').val(data.id);
            $('#userName').val(data.name);
        }
        $('#myModal').modal('toggle');
    }

    function show_list(){
        $('#myModal').modal('toggle');
    }
</script>